/*
 * @lc app=leetcode.cn id=14 lang=javascript
 *
 * [14] 最长公共前缀
 */

// @lc code=start
/**
 * @param {string[]} strs
 * @return {string}
 */
var longestCommonPrefix = function(strs) {
    if(strs.length==0){return ""}
    let res=strs.reduce((a,b)=>{
        let c=""
        for(let i=0;i<a.length&&i<b.length;i++){
            if(a[i]==b[i]){
                c=c+a[i]
            }
            else{
                break
            }
        } 
        return c
    })
    return res
};
// @lc code=end
a=longestCommonPrefix(["aca","cba"])
console.log(a)